home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 February / EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso / earcd / util1 / yk211src.lha / Yak_2.11_Src / Prefs / gui.c < prev    next >
C/C++ Source or Header  |  1995-11-16  |  17KB  |  812 lines

  1. /*
  2.  * GUI.c
  3.  * 
  4.  * Contains high level common functions used by all the windows of Yak GUI
  5.  * 
  6.  */
  7.  
  8. #include <exec/execbase.h>
  9. #include <exec/types.h>
  10. #include <exec/memory.h>
  11. #include <diskfont/diskfont.h>
  12. #include <graphics/text.h>
  13. #include <intuition/intuition.h>
  14. #include <intuition/intuitionbase.h>
  15. #include <libraries/gadtools.h>
  16. #include <workbench/workbench.h>
  17.  
  18. #include <proto/exec.h>
  19. #include <proto/diskfont.h>
  20. #include <proto/dos.h>
  21. #include <proto/intuition.h>
  22. #include <proto/gadtools.h>
  23. #include <proto/graphics.h>
  24. #include <proto/wb.h>
  25.  
  26. #include <string.h>
  27.  
  28. #ifdef MUI
  29. #include <libraries/mui.h>
  30. #include <proto/muimaster.h>
  31. #endif
  32.  
  33. #ifdef BGUI
  34. #include <libraries/bgui.h>
  35. #include <libraries/bgui_macros.h>
  36. #include <proto/bgui.h>
  37. #include <clib/alib_protos.h>
  38. #endif
  39.  
  40. #include "Code.h"
  41. #include "yak.h"
  42. #include "version.h"
  43. #include "GetPubScreen.h"
  44. #include "GetScreenBox.h"
  45. #include "Hotkey_types.h"
  46. #include "Root_window.h"
  47. #include "MouseCycling_window.h"
  48. #include "Options_window.h"
  49. #include "KeyDef_window.h"
  50. #include "Blank_window.h"
  51. #include "Misc_window.h"
  52. #include "Hotkey_window.h"
  53. #include "Requesters.h"
  54. #include "Settings.h"
  55. #include "gui.h"
  56.  
  57. #include "yak_locale_strings.h"
  58.  
  59. IMPORT struct MsgPort *AppMsgPort;
  60.  
  61. #ifdef BETA_VERSION
  62. static UBYTE DisplayBetaRequester = TRUE;
  63. #endif
  64.  
  65. struct Window           *curwin = NULL;
  66. UBYTE                    curwinID = ROOT_WINDOW;
  67.  
  68.  
  69. #ifdef MUI
  70.  
  71. APTR                    *curwinobj = NULL;
  72.  
  73. #endif
  74.  
  75. #ifdef BGUI
  76.  
  77. Object                  *curwinobj = NULL;
  78. struct TextAttr          Attr;
  79. char                     FontName[50];
  80. int                      FontSize;
  81. struct TextFont         *TextFont = NULL;
  82. UBYTE                   *PubScreenName = NULL;
  83. ULONG                    appwinsigflag = 0;
  84.  
  85. #endif
  86.  
  87.  
  88.  
  89. IMPORT APTR App;
  90.  
  91.  
  92.  
  93. #ifdef GADTOOLS      /* GadTools Specific Code */
  94.  
  95. struct Screen   *Scr = NULL;
  96. UBYTE           *PubScreenName;
  97. APTR             VisualInfo = NULL;
  98. struct TextAttr *Font,Attr;
  99. UWORD            FontX,FontY; 
  100. UWORD            OffX,OffY;
  101. WORD             WindowTop = 0;
  102. WORD             WindowLeft = 0;
  103.  
  104. char  FontName[50];
  105. int   FontSize;
  106. static struct TextFont *TextFont=NULL;
  107.  
  108.  
  109.  
  110. int 
  111. SetupScreen(VOID)
  112. {
  113.     struct Screen *s;
  114.     ULONG lock;
  115.  
  116.     /* Choose a public screen to open our window */
  117.     lock = LockIBase(0);
  118.     s = IntuitionBase->ActiveScreen;
  119.     UnlockIBase(lock);
  120.   
  121.     PubScreenName = GetPubScreenName(s);
  122.  
  123.     if (! (Scr = LockPubScreen(PubScreenName)))
  124.         return(1L);
  125.  
  126.     ScreenToFront(Scr);
  127.  
  128.     ComputeFont(0,0);
  129.  
  130.     if (! (VisualInfo = GetVisualInfo(Scr,TAG_DONE)))
  131.         return(2L);
  132.  
  133.     return(0L);
  134. }
  135.  
  136.  
  137.  
  138. void 
  139. CloseDownScreen(VOID)
  140. {
  141.     if (VisualInfo) {
  142.         FreeVisualInfo(VisualInfo);
  143.         VisualInfo = NULL;
  144.     }
  145.  
  146.     if (Scr) {
  147.         UnlockPubScreen(NULL,Scr);
  148.         Scr = NULL;
  149.     }
  150. }
  151.  
  152.  
  153.  
  154. UWORD 
  155. ComputeX(UWORD value)
  156. {
  157.         return((UWORD)(((FontX*value)+4)/8));
  158. }
  159.  
  160.  
  161. UWORD 
  162. ComputeY(UWORD value)
  163. {
  164.         return((UWORD)(((FontY*value)+4)/8));
  165. }
  166.  
  167.  
  168. VOID
  169. UseTopaz(VOID)
  170. {
  171.     Font->ta_Name = (STRPTR)"topaz.font";
  172.     FontX = FontY = Font->ta_YSize = 8;
  173. }
  174.  
  175.  
  176. UWORD 
  177. CalcFontX(struct TextFont *TFont)
  178. {
  179.     static struct RastPort DummyRastPort;
  180.     UWORD                  result;
  181.  
  182.     if (TFont)
  183.     {
  184.         /* compute font width for the specified font */
  185.         SetFont(&DummyRastPort, TextFont);
  186.         result = (UWORD)TextLength(&DummyRastPort,"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",52)/52 ;
  187.     }
  188.     else
  189.     {
  190.         /* compute font width for screen font */
  191.         result = (UWORD)TextLength(&Scr->RastPort,"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",52)/52 ;
  192.     }
  193.     return(result);
  194. }
  195.  
  196.  
  197. VOID 
  198. ComputeFont(UWORD width,UWORD height)
  199. {
  200.     Font = &Attr;
  201.  
  202.     OffX = Scr->WBorLeft;
  203.     OffY = Scr->RastPort.TxHeight +Scr->WBorTop +1;
  204.  
  205.     if (strlen(FontName)>0)
  206.     {
  207.         Font->ta_Name = (STRPTR)FontName;
  208.         Font->ta_YSize = FontY = (UWORD)FontSize;
  209.     }
  210.     else
  211.     {
  212.         Font->ta_Name = (STRPTR)Scr->RastPort.Font->tf_Message.mn_Node.ln_Name;
  213.         Font->ta_YSize = FontY = Scr->RastPort.Font->tf_YSize;
  214.     }
  215.  
  216.     if (TextFont)
  217.     {
  218.         CloseFont(TextFont);
  219.     }
  220.  
  221.     TextFont = OpenDiskFont(Font);
  222.  
  223.     FontX = CalcFontX(TextFont);
  224.  
  225.     /* Don't go under 8 points */
  226.     if (FontY < 8) FontY = 8;
  227.  
  228.     if (width && height)
  229.     {
  230.         if (((ComputeX(width) + OffX + Scr->WBorRight) > Scr->Width) ||
  231.             ((ComputeY(height) + OffY + Scr->WBorBottom) > Scr->Height) ||
  232.             (TextFont == NULL))
  233.         {
  234.             UseTopaz();
  235.         }
  236.     }
  237. }
  238.  
  239.  
  240.  
  241. __regargs void
  242. DrawThinBevelBox(struct Screen *Screen, struct RastPort *rp,
  243.                                  long Left, long Top, long Width, long Height, BOOL Recess)
  244. {
  245.     struct DrawInfo *ScreenDrawInfo;
  246.  
  247.     ScreenDrawInfo = GetScreenDrawInfo(Screen);
  248.     SetAPen(rp, ScreenDrawInfo->dri_Pens[(Recess) ? SHADOWPEN : SHINEPEN]);
  249.     Move(rp, Left, Top + Height - 1);
  250.     Draw(rp, Left, Top);
  251.     Draw(rp, Left + Width - 1, Top);
  252.     SetAPen(rp, ScreenDrawInfo->dri_Pens[(Recess) ? SHINEPEN : SHADOWPEN]);
  253.     Draw(rp, Left + Width - 1, Top + Height - 1);
  254.     Draw(rp, Left + 1, Top + Height - 1);
  255.     FreeScreenDrawInfo(Screen, ScreenDrawInfo);
  256. }
  257.  
  258.  
  259. /* Localize gadget labels, locale strings identifiers are stored in UserData filed */
  260. __regargs void
  261. LocalizeNGadLabels (UBYTE Gadgets_Num, struct NewGadget *NGad)
  262. {
  263.     UWORD i;
  264.  
  265.     for (i=0; i<Gadgets_Num; i++)
  266.     {
  267.         if (NGad[i].ng_UserData)
  268.         {
  269.             NGad[i].ng_GadgetText = getString(NGad[i].ng_UserData);
  270.         }
  271.     }
  272. }
  273.  
  274.  
  275. static __regargs VOID
  276. SetWindowUnderMouse (UWORD Width, UWORD Height, WORD *Left, WORD *Top)
  277. {
  278.     WORD MouseY, MouseX;
  279.  
  280.     /* Where is our mouse pointer? */
  281.     MouseX = Scr->MouseX;
  282.     MouseY = Scr->MouseY;
  283.  
  284.     /* Is our pointer above the window to open ? */
  285.     if ((MouseX >= *Left) && (MouseX <= (*Left+Width)) &&
  286.         (MouseY >= *Top) && (MouseY <= (*Top+Height)))
  287.     {
  288.         /* Yes, so we don't have to move our window */
  289.     }
  290.     else
  291.     {
  292.         /* No, so we have to move our window only by what is needed */
  293.  
  294.         if ((MouseX < *Left) || (MouseX > (*Left+Width)))
  295.             *Left = MouseX - Width;
  296.  
  297.         if ((MouseY < *Top) || (MouseY > (*Top+Height)))
  298.             *Top = MouseY - Height;
  299.     }
  300.  
  301. }
  302.  
  303. __regargs void
  304. SetUpWindowCoordinates( UWORD Width, UWORD Height, WORD *Left, WORD *Top)
  305. {
  306.  
  307.     struct IBox     box;
  308.  
  309.         /* If AutoPoint is enabled, we want the window to be openned 
  310.      * under mouse pointer 
  311.      */
  312.         if (autopoint)
  313.                 SetWindowUnderMouse (Width, Height, Left, Top);
  314.  
  315.     /* Check boundaries, especially for autoscroll screens */
  316.  
  317.     GetScreenBox(Scr, &box, TRUE);
  318.  
  319.     if (*Left < box.Left) 
  320.         *Left = box.Left;
  321.     if (*Top < box.Top) 
  322.         *Top = box.Top;
  323.     if ((*Left + Width) > box.Left + box.Width) 
  324.         *Left = box.Left + box.Width - Width;
  325.     if ((*Top +  Height) > box.Top + box.Height) 
  326.         *Top = box.Top + box.Height - Height;
  327. }
  328.  
  329. #endif  /* GadTools Specific Code */
  330.  
  331. #ifdef BGUI                                     /* BGUI specific code NMC */
  332. int SetupScreen(VOID)
  333. {
  334.     struct Screen *s;
  335.     ULONG lock;
  336.  
  337.     /* Choose a public screen to open our window */
  338.     lock = LockIBase(0);
  339.     s = IntuitionBase->ActiveScreen;
  340.     UnlockIBase(lock);
  341.   
  342.     PubScreenName = GetPubScreenName(s);
  343.  
  344.     return(0L);
  345. }
  346. #endif
  347.  
  348. /* initialise individual gadget in specified window */
  349. #ifdef GADTOOLS    /* GadTools Version */
  350. __regargs void
  351. InitWindowGadget(UWORD num, LONG tagtype, LONG tagvalue, UBYTE WindowID)
  352. {
  353.     switch(WindowID)
  354.     {
  355.       case ROOT_WINDOW:
  356.         GT_SetGadgetAttrs(RootGadgets[num], RootWnd, NULL, tagtype, tagvalue, TAG_DONE);
  357.         break;
  358.  
  359.       case HOTKEY_WINDOW:
  360.         GT_SetGadgetAttrs(HotKeyGadgets[num], HotKeyWnd, NULL, tagtype, tagvalue, TAG_DONE);
  361.         break;
  362.  
  363.       case MISC_WINDOW:
  364.         GT_SetGadgetAttrs(MiscGadgets[num], MiscWnd, NULL, tagtype, tagvalue, TAG_DONE);
  365.         break;
  366.  
  367.       case BLANK_WINDOW:
  368.         GT_SetGadgetAttrs(BlankGadgets[num], BlankWnd, NULL, tagtype, tagvalue, TAG_DONE);
  369.         break;
  370.  
  371.       case MCYCLING_WINDOW:
  372.         GT_SetGadgetAttrs(MouseCyclingGadgets[num], MouseCyclingWnd, NULL, tagtype, tagvalue, TAG_DONE);
  373.         break;
  374.  
  375.       case KEYDEF_WINDOW:
  376.         GT_SetGadgetAttrs(KeyDefGadgets[num], KeyDefWnd, NULL, tagtype, tagvalue, TAG_DONE);
  377.         break;
  378.     }
  379. }
  380.  
  381. #endif
  382. #ifdef MUI           /* MUI version */
  383. __regargs void
  384. InitWindowGadget(UWORD num, LONG tagtype, LONG tagvalue, UBYTE WindowID)
  385. {
  386.     switch(WindowID)
  387.     {
  388.       case ROOT_WINDOW:
  389.         SetAttrs(RootObjects[num], MUIA_NoNotify, TRUE, tagtype, tagvalue, TAG_DONE);
  390.         break;
  391.  
  392.       case HOTKEY_WINDOW:
  393.         SetAttrs(HotKeyObjects[num], MUIA_NoNotify, TRUE, tagtype, tagvalue, TAG_DONE);
  394.         break;
  395.  
  396.       case MISC_WINDOW:
  397.         SetAttrs(MiscObjects[num], MUIA_NoNotify, TRUE, tagtype, tagvalue, TAG_DONE);
  398.         break;
  399.  
  400.       case BLANK_WINDOW:
  401.         SetAttrs(BlankObjects[num], MUIA_NoNotify, TRUE, tagtype, tagvalue, TAG_DONE);
  402.         break;
  403.  
  404.       case MCYCLING_WINDOW:
  405.         SetAttrs(MouseCyclingObjects[num], MUIA_NoNotify, TRUE, tagtype, tagvalue, TAG_DONE);
  406.         break;
  407.  
  408.       case KEYDEF_WINDOW:
  409.         SetAttrs(KeyDefObjects[num], MUIA_NoNotify, TRUE, tagtype, tagvalue, TAG_DONE);
  410.         break;
  411.     }
  412. }
  413.  
  414. #endif
  415. #ifdef BGUI           /* BGUI version  NMC */
  416. __regargs void
  417. InitWindowGadget(UWORD num, LONG tagtype, LONG tagvalue, UBYTE WindowID)
  418. {
  419.     switch(WindowID)
  420.     {
  421.       case ROOT_WINDOW:
  422.         SetGadgetAttrs((struct Gadget *)RootObjects[num], RootWnd, NULL,
  423.                         tagtype, tagvalue, TAG_DONE);
  424.         break;
  425.  
  426.       case BLANK_WINDOW:
  427.         SetGadgetAttrs((struct Gadget *)BlankObjects[num], BlankWnd, NULL,
  428.                         tagtype, tagvalue, TAG_DONE);
  429.         break;
  430.  
  431.       case MISC_WINDOW:
  432.         SetGadgetAttrs((struct Gadget *)MiscObjects[num], MiscWnd, NULL,
  433.                         tagtype, tagvalue, TAG_DONE);
  434.         break;
  435.  
  436.       case MCYCLING_WINDOW:
  437.         SetGadgetAttrs((struct Gadget *)MouseCyclingObjects[num], MouseCyclingWnd, NULL,
  438.                         tagtype, tagvalue, TAG_DONE);
  439.         break;
  440.  
  441.       case HOTKEY_WINDOW:
  442.         SetGadgetAttrs((struct Gadget *)HotKeyObjects[num], HotKeyWnd, NULL,
  443.                         tagtype, tagvalue, TAG_DONE);
  444.         break;
  445.  
  446.       case KEYDEF_WINDOW:
  447.         SetGadgetAttrs((struct Gadget *)KeyDefObjects[num], KeyDefWnd, NULL,
  448.                         tagtype, tagvalue, TAG_DONE);
  449.         break;
  450.     }
  451. }
  452.  
  453. #endif
  454.  
  455.  
  456.  
  457. /* Init Toggles: Shared Code */
  458. #ifdef GADTOOLS
  459. #    define CHECKMARK_TAG GTCB_Checked
  460. #endif
  461. #ifdef MUI
  462. #    define CHECKMARK_TAG MUIA_Selected
  463. #endif
  464. #ifdef BGUI             /* NMC */
  465. #    define CHECKMARK_TAG GA_Selected
  466. #endif
  467.  
  468. __regargs void
  469. InitToggleGadgets( UBYTE WindowID )
  470. {
  471.     UWORD   i;
  472.     for (i = 0; i < NUM_TOGGLES; i++)
  473.         if ((toggles[i].gadid != OBSOLETE_TOGGLE) &&
  474.             (toggles[i].winid == WindowID))
  475.         {
  476.             InitWindowGadget(toggles[i].gadid,
  477.                              CHECKMARK_TAG,
  478.                              toggles[i].pos,
  479.                              WindowID); 
  480.         }
  481. }
  482.  
  483.  
  484.  
  485. /* Handle pattern string-gadget */
  486. #ifdef GADTOOLS   /* GadTools Version */
  487. __regargs void
  488. NewPattern(UWORD gdx, PatternData *pdata, struct Gadget *gad, UBYTE WindowID)
  489. {
  490.     char *newpatstr;
  491.  
  492.     newpatstr = GetString(gad);
  493.     if (!InitPattern(newpatstr, pdata))
  494.     {
  495.         InitWindowGadget(gdx, GTST_String, (LONG)pdata->patstr, WindowID);
  496.     }
  497. }
  498. #endif
  499. #ifdef MUI           /* MUI Version */
  500. __regargs void
  501. NewPattern(UWORD gdx, PatternData *pdata, struct Gadget *gad, UBYTE WindowID)
  502. {
  503.     char *newpatstr;
  504.  
  505.     GetAttr(MUIA_String_Contents, gad, (ULONG *)&newpatstr);
  506.     if (!InitPattern(newpatstr, pdata))
  507.     {
  508.         InitWindowGadget(gdx, MUIA_String_Contents, (LONG)pdata->patstr, WindowID);
  509.     }
  510. }
  511. #endif
  512. #ifdef BGUI           /* BGUI Version NMC */
  513. __regargs void
  514. NewPattern(UWORD gdx, PatternData *pdata, struct Gadget *gad, UBYTE WindowID)
  515. {
  516.     char *newpatstr;
  517.  
  518.     GetAttr(STRINGA_TextVal, gad, (ULONG *)&newpatstr);
  519.     if (!InitPattern(newpatstr, pdata))
  520.     {
  521.         InitWindowGadget(gdx, STRINGA_TextVal, (LONG)pdata->patstr, WindowID);
  522.     }
  523. }
  524. #endif
  525.  
  526.  
  527.  
  528. /* Disable/Enable the GUI */
  529. #ifdef GADTOOLS   /* GadTools Version */
  530.  
  531. /* Wait pointer image data */
  532. __chip static UWORD WaitPointer[] = {
  533.         0x0000, 0x0000,
  534.         0x0400, 0x07c0, 
  535.         0x0000, 0x07c0, 
  536.         0x0100, 0x0380, 
  537.         0x0000, 0x07e0, 
  538.         0x07c0, 0x1ff8,
  539.         0x1ff0, 0x3fec, 
  540.         0x3ff8, 0x7fde, 
  541.         0x3ff8, 0x7fbe, 
  542.         0x7ffc, 0xff7f, 
  543.         0x7efc, 0xffff,
  544.         0x7ffc, 0xffff, 
  545.         0x3ff8, 0x7ffe, 
  546.         0x3ff8, 0x7ffe, 
  547.         0x1ff0, 0x3ffc, 
  548.         0x07c0, 0x1ff8,
  549.         0x0000, 0x07e0,
  550.  
  551.         0x0000, 0x0000
  552. };
  553.  
  554. static struct Requester DummyReq;
  555. static ULONG  IDCMPFlags;
  556.  
  557.  
  558. void 
  559. DisableYakInterface(VOID)
  560. {
  561.     if (curwin)
  562.     {
  563.         /* Disable IDCMP */
  564.         IDCMPFlags = ((struct Window *)curwin)->IDCMPFlags;
  565.         ModifyIDCMP(curwin, IDCMP_REFRESHWINDOW);
  566.  
  567.         /* Init dummy requester structure */
  568.         InitRequester(&DummyReq);
  569.  
  570.         /* Block window input */
  571.         Request(&DummyReq, curwin);
  572.  
  573.         /* Set wait pointer */
  574.         if (SysBase->LibNode.lib_Version >= 39)
  575.             SetWindowPointer(curwin, WA_BusyPointer, TRUE, TAG_DONE);
  576.         else
  577.             SetPointer(curwin, WaitPointer, 16, 16, -6, 0);
  578.     }
  579. }
  580.  
  581.  
  582. void 
  583. EnableYakInterface(VOID)
  584. {
  585.     /* Clear wait pointer */
  586.     if (SysBase->LibNode.lib_Version >= 39)
  587.         SetWindowPointer(curwin, TAG_DONE);
  588.     else
  589.         ClearPointer(curwin);
  590.  
  591.     /* Enable window input */
  592.     EndRequest(&DummyReq, curwin);
  593.  
  594.     /* Enable IDCMP */
  595.     ModifyIDCMP(curwin, IDCMPFlags);
  596. }
  597.  
  598. #endif
  599. #ifdef MUI        /* MUI Version */
  600.  
  601. void 
  602. DisableYakInterface(VOID)
  603. {
  604.     set(App, MUIA_Application_Sleep, TRUE);
  605. }
  606.  
  607.  
  608. void 
  609. EnableYakInterface(VOID)
  610. {
  611.     set(App, MUIA_Application_Sleep, FALSE);
  612. }
  613.  
  614. #endif
  615. #ifdef BGUI        /* BGUI Version NMC */
  616. void 
  617. DisableYakInterface(VOID)
  618. {
  619.         WindowBusy(curwinobj);
  620. }
  621.  
  622.  
  623. void 
  624. EnableYakInterface(VOID)
  625. {
  626.         WindowReady(curwinobj);
  627. }
  628. #endif
  629.  
  630.  
  631. /* show current window */
  632. BOOL
  633. ShowYakInterface(VOID)
  634. {
  635.     BOOL OK;
  636.         
  637. #ifdef BETA_VERSION
  638.     if (DisplayBetaRequester == TRUE)
  639.     {
  640.         PostError("This is " VERSION_NAME " beta version\nBuilt on " __DATE__);
  641.         DisplayBetaRequester = FALSE;
  642.     }
  643. #endif
  644.  
  645.     if (curwin)             /* already opened */
  646.     {
  647.        ScreenToFront(((struct Window *)curwin)->WScreen);
  648.        WindowToFront(curwin);
  649.        ActivateWindow(curwin);
  650.        return TRUE;
  651.     }
  652.  
  653. #ifndef MUI
  654.     if (!(OK=SetupScreen()))
  655.     {
  656.        OK = ShowWindowID(curwinID);
  657.     }
  658. #else
  659.        OK = ShowWindowID(curwinID);
  660. #endif
  661.  
  662.     if (!OK)
  663.         PostError(getString(Couldnt_open_GUI_ERR));
  664.     return(OK);
  665. }
  666.  
  667.  
  668.  
  669.  
  670. BOOL
  671. ShowWindowID(UBYTE WindowID)
  672. {
  673.     BOOL OK;
  674.  
  675.     switch(WindowID)
  676.     {
  677.       case ROOT_WINDOW:
  678.         OK = ShowRootWindow();
  679.         break;
  680.  
  681.       case HOTKEY_WINDOW:
  682.         OK = ShowHotKeyWindow();
  683.         break;
  684.  
  685.       case MISC_WINDOW:
  686.         OK = ShowMiscWindow();
  687.         break;
  688.  
  689.       case BLANK_WINDOW:
  690.         OK = ShowBlankWindow();
  691.         break;
  692.  
  693.       case MCYCLING_WINDOW:
  694.         OK = ShowMouseCyclingWindow();
  695.         break;
  696.  
  697.       case KEYDEF_WINDOW:
  698.         OK = ShowKeyDefWindow();
  699.         break;
  700.         
  701.       case OPTIONS_WINDOW:
  702.         OK = ShowOptionsWindow();
  703.         break;
  704.  
  705.     }
  706.  
  707.     if (OK)
  708.     {
  709.         ActivateWindow(curwin);
  710.     }
  711.     else
  712.     {
  713.         PostError(getString(Couldnt_open_other_window_ERR));
  714.     }
  715.     return(OK);
  716. }
  717.  
  718.  
  719. VOID 
  720. CloseWindowID(UBYTE WindowID)
  721. {
  722.     switch(WindowID)
  723.     {
  724.       case ROOT_WINDOW:
  725.         CloseRootWindow();
  726.         break;
  727.  
  728.       case HOTKEY_WINDOW:
  729.         CloseHotKeyWindow();
  730.         break;
  731.  
  732.       case MISC_WINDOW:
  733.         CloseMiscWindow();
  734.         break;
  735.  
  736.       case BLANK_WINDOW:
  737.         CloseBlankWindow();
  738.         break;
  739.  
  740.       case KEYDEF_WINDOW:
  741.         CloseKeyDefWindow();
  742.         break;
  743.  
  744.       case MCYCLING_WINDOW:
  745.         CloseMouseCyclingWindow();
  746.         break;
  747.         
  748.       case OPTIONS_WINDOW:
  749.         CloseOptionsWindow();
  750.         break;
  751.     }
  752.  
  753.     curwin = NULL;
  754. #if defined(MUI) || defined(BGUI)
  755.     curwinobj = NULL;
  756. #endif
  757. }
  758.  
  759.  
  760. #ifdef GADTOOLS   /* GadTools Version */
  761. void
  762. CloseOneWindow (struct Window *Wnd, 
  763.                 struct Menu *Menus, struct Gadget *GList, struct AppWindow *AppWin)
  764. {
  765.     /* Save coordinates of current window */
  766.  
  767.     WindowTop  = Wnd->TopEdge;
  768.     WindowLeft = Wnd->LeftEdge;
  769.  
  770.     if (AppWin)
  771.     {
  772.         RemoveAppWindow(AppWin);
  773.     }
  774.  
  775.     FreeMenus(Menus);
  776.  
  777.     if (Wnd) 
  778.     {
  779.         ClearMenuStrip(Wnd);
  780.         CloseWindow(Wnd);
  781.     }
  782.     
  783.     FreeGadgets(GList);
  784. }
  785.  
  786. #endif
  787. #ifdef MUI       /* MUI Version */
  788. #endif
  789. #ifdef BGUI      /* BGUI Version NMC */
  790. #endif
  791.  
  792.  
  793. /* hide our window */
  794. void
  795. HideInterface(VOID)
  796. {
  797.     if (curwin)
  798.     {
  799.         CloseWindowID(curwinID);
  800. #ifdef GADTOOLS
  801.         CloseDownScreen();
  802. #endif
  803.     }
  804. #ifdef GADTOOLS
  805.     if (TextFont)
  806.     {
  807.         CloseFont(TextFont);
  808.     }
  809. #endif
  810. }
  811.  
  812.